﻿@model SimpleTaskManager.Domain.Entities.User
@using SimpleTaskManager.Domain.Entities;

<table>
    <thead>
        <tr>
            <th>Skill</th>
            <th>Rating</th>
            @if(ViewBag.DisplayDelete){<th></th>}
        </tr>
    </thead>
    <tbody>
        @foreach(User_Skill mySkill in Model.User_Skills) {
            <tr>
                <td>@mySkill.Skill.Name</td>
                <td>@mySkill.Rating @((mySkill.ApprovedById != null) ? "(by " : "")
                @if(mySkill.ApprovedBy != null){
                    @Html.ActionLink(mySkill.ApprovedBy.FirstName + " " + mySkill.ApprovedBy.LastName, "Details", new { id = mySkill.ApprovedById });
                } @((mySkill.ApprovedById != null) ? ")" : "")
                @((ViewBag.CanRate) ? "|" : "")
                @if (ViewBag.CanRate)
                {
                    @Html.ActionLink("Rate", "RateSkill", new { id = mySkill.User_SkillID});
                }
                </td>
                @if (ViewBag.DisplayDelete)
                {
                    <td>@Html.ActionLink("Delete", "DeleteSkill", new { id = mySkill.User_SkillID })</td>
                }
            </tr>
        }
    </tbody>
</table>

<script>
    $(document).ready(function () {
        $("tr td a:contains('Delete')").click(function () {
            if (confirm("Are you sure you want to delete this?")) {
                return true;
            } else {
                return false;
            }
        });
    });
</script>